package com.deyuanyun.pic.pbf.controller.dto.defect.measure;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pbf.domain.DefectInfo;
import com.deyuanyun.pic.pbf.domain.DefectMeasure;

/**
 * “椭圆变形”缺陷测量记录
 *
 * @author huanglw
 * @date 2016-6-28
 *
 * History: [修改人][时间][修改描述]
 */
public class EllipticDeformMeasureDto extends MeasureDto<DefectMeasure> {

    /**
     * 绝对距离
     */
    private String mileage;

    /**
     * 椭圆最大变形量（%OD）--椭圆变形
     */
    private String maxDeformation;

    /**
     * 长（mm）
     */
    private String length;

    /**
     * 实测：椭圆最大变形量（%OD）--椭圆变形
     */
    private String actualMaxDeformation;

    /**
     * 实测：长（mm）
     */
    private String actualLength;

    /**
     * 是否完成该节点任务：0，没有完成；1，已经完成
     */
    private Short isCompletion;

    public EllipticDeformMeasureDto(Short isCompletion) {
        this.isCompletion = isCompletion;
    }

    public Short getIsCompletion() {
        return isCompletion;
    }

    public void setIsCompletion(Short isCompletion) {
        this.isCompletion = isCompletion;
    }

    public EllipticDeformMeasureDto(DefectInfo defectInfo, Short isCompletion) {
        super(defectInfo);
        this.isCompletion = isCompletion;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getMaxDeformation() {
        return maxDeformation;
    }

    public void setMaxDeformation(String maxDeformation) {
        this.maxDeformation = maxDeformation;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public String getActualLength() {
        return actualLength;
    }

    public void setActualLength(String actualLength) {
        this.actualLength = actualLength;
    }

    public String getActualMaxDeformation() {
        return actualMaxDeformation;
    }

    public void setActualMaxDeformation(String actualMaxDeformation) {
        this.actualMaxDeformation = actualMaxDeformation;
    }

    public void fromDomain(DefectMeasure domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 赋值
        super.fromDomain(domain);

        // 绝对距离
        this.mileage = NumberFormat.format(defectInfo.getMileage());
        // 椭圆最大变形量（%OD）--椭圆变形 (由于没有最小变形量了，只有长和最大变形量。小长大宽)
        this.maxDeformation = NumberFormat.format(defectInfo.getWidth());
        // 长（mm）
        this.length = NumberFormat.format(defectInfo.getLength());
        // 实测：椭圆最大变形量（%OD）--椭圆变形
        this.actualMaxDeformation = NumberFormat.format(domain.getActualWidth());
        // 实测：长（mm）
        this.actualLength = NumberFormat.format(domain.getActualLength());
    }
}